<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'MyJsp.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<jsp:include page="/scripts/common/index.html"></jsp:include>
<jsp:include page="/scripts/dhtmlx/index.html"></jsp:include>
<jsp:include page="/scripts/jquery/index.html"></jsp:include>
<jsp:include page="/scripts/bootstrap/index.html"></jsp:include>
<link rel="stylesheet" href="${basepath }style/default.css">
</head>
<script type="text/javascript">
	var temp = false;
	var mygrid_tab_status;
	var orgTree, treeId;
	var fileGroupId;//文件组id
	function init() {
		
	}
	
	function save() {
			$('#MyForm').bootstrapValidator('validate');
			if (temp) {
				$.ajax({
					type : 'POST' ,
					url : 'page/system/manage/Index/doUpdPassword' ,
					data : $('#MyForm').serializeArray() ,
					dataType : "json" ,
					async : true ,
					cache : false ,
					jsonpCallback : "null" ,
					success : function(response, status, statusText) {
						if (response.status) {
							if (response.content == "修改成功！") {//type != 1
								//SN.clearFormValue("MyForm");
								logout();
							} else if (response.content == "修改失败！") {
								//SN.clearFormValue("MyForm");
								SN.alert.info("修改失败！", function() {
								});
							}
						} else {
							SN.alert.info(response.content);
						}
					} ,
					error : function(response, status, statusText) {
						//alert(response + ":" + status + ":" + statusText);
					} ,
					complete : function(response, status, statusText) {
						//alert(response + ":" + status + ":" + statusText);
					}
				});
			}
		/* }else{
			SN.alert.info("原始密码与当前登录密码不一致！");
		} */
		
	}
	function logout() {
		SN.alert.confirm("修改成功，是否退出本系统重新登录？", function(obj) {
			if (obj) {
				$.ajax({
						type : 'POST' ,
						url : 'page/system/manage/Logout/doLogout' ,
						data : {} ,
						dataType : "json" ,
						async : true ,
						cache : false ,
						jsonpCallback : "null" ,
						//beforeSend : function(response, status, statusText) {
						//alert(response + ":" + status + ":" + statusText);
						//} ,
						//dataFilter : function(response, status, statusText) {
						//alert(response + ":" + status + ":" + statusText);
						//} ,
						success : function(response, status, statusText) {
							//alert(response + ":" + status + ":" + statusText);
							if (response.status) {
								window.location.reload();
							} else {
								alert(response.content);
							}
						} ,
						error : function(response, status, statusText) {
							//alert(response + ":" + status + ":" + statusText);
						} ,
						complete : function(response, status, statusText) {
							//alert(response + ":" + status + ":" + statusText);
						}
				});
			}else{
				closeWindow();
			}
		});
	}
	function closeWindow() {
		parent.closeWindow();
	}
	//回到顶部按钮添加
	$(document).ready(function () {
            GP.goup({
                trigger: 100,
                bottomOffset: 30,
                locationOffset: 30,
                titleAsText: true,
               containerColor: '#7e7f7e'
            },"Panel_");
    });
		
	$(document).ready(function() {
		$('#MyForm').bootstrapValidator({
			message : 'This value is not valid' ,
			icon : {
				valid : 'glyphicon glyphicon-ok' ,
				invalid : 'glyphicon glyphicon-remove' ,
				validating : 'glyphicon glyphicon-refresh'
			} ,
			fields : {
				
				"map.oldPassword" : {
					row : '.col-xs-6' ,
					validators : {
						notEmpty : {
							message : '密码不能为空'
						} ,
						regexp : {
							regexp : /^[a-zA-Z0-9_]{6,10}$/ ,
							message : '由6-10位数字英文或者下划线组成 '
						}
					}
				},
				
				"map.password": {
					row : '.col-xs-6' ,
					validators : {
						notEmpty : {
							message : '密码不能为空'
						} ,
						regexp : {
							regexp : /^[a-zA-Z0-9_]{6,10}$/ ,
							message : '由6-10位数字英文或者下划线组成 '
						}
					}
	             },
	            "secondPassword" : {
	            	row : '.col-xs-6' ,
	            	 validators: {
	            		 notEmpty : {
								message : '密码不能为空'
							} ,
	                    identical: {
	                        field: 'map.password',
	                        message: '与新密码不一致'
	                    }
	                }

				}
			}
		}).on('success.form.bv', function(e) {
			//alert("验证成功");
			temp = true;
			return temp;
		}).on('error.form.bv', function(e) {
			SN.alert.info("验证失败");
			temp = false;
			return temp;
		});
	});
</script>
<script type="text/javascript">
	function closeWindow() {
		parent.w1.close();
	}
</script>

<body onload="init()" marginleft="0" margintop="0" style="margin: 0px;border: 0">
	<form class="form-horizontal MyForm" id="MyForm" name="MyForm" method="post" target="MyFrame" enctype="multipart/form-data">
		<table class="contTable">
			<tr class="firstTr">
				<td>
					<button onclick="save()" class="btn btn-primary aButton" type="button">
						<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>&nbsp;<span>保存</span>
					</button>
				</td>
			</tr>
			<tr style="height:auto">
				<td valign="top">
					<div id="Panel_" style="width:100%;height:200px;overflow-y:auto;">
						<div class="blockBorder">
							<div class="tableCont" style="width: 90%;">
								
								<div class="form-group">
									<label class="col-xs-4 control-label" for="oldPassword">原始密码 :</label>
									<div class="col-xs-6">
										<input class="form-control" name="map.oldPassword" id="oldPassword" value="" type="input" onfocus="this.type='password'" placeholder="" />
									</div>
									<div class="col-xs-1 ">
										<span class="required">*</span>
									</div>
								</div>
								<div class="form-group">
									<label class="col-xs-4 control-label" for="password">新密码:</label>
									<div class="col-xs-6">
										<input class="form-control" name="map.password" id="password" value="" type="input" onfocus="this.type='password'" placeholder="" />
									</div>
									<div class="col-xs-1 ">
										<span class="required">*</span>
									</div>
								</div>
								<div class="form-group">
									<label class="col-xs-4 control-label" for="secondPassword">确认密码:</label>
									<div class="col-xs-6">
										<input class="form-control" name="secondPassword" id="secondPassword" value="" type="input" onfocus="this.type='password'" placeholder="" />
									</div>
									<div class="col-xs-1 ">
										<span class="required">*</span>
									</div>
								</div>
							</div>
						</div>
						
					</div>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
